<template>
  <div class="user-manage-bg">
    <div class="user-manage-header">
      <el-button class="back-btn" type="primary" link @click="goHome">
        <i class="el-icon-arrow-left"></i> 返回首页
      </el-button>
    </div>
    <div class="user-manage-center">
      <el-card class="user-info-card">
        <el-table :data="userList" border style="width: 100%">
          <el-table-column prop="id" label="ID" width="80" />
          <el-table-column prop="name" label="用户名" />
          <el-table-column prop="accountNumber" label="账号" />
          <el-table-column label="密码">
            <template #default>
              <span>******</span>
            </template>
          </el-table-column>
          <el-table-column prop="role" label="角色" />
        </el-table>
      </el-card>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import axios from "axios";
const userList = ref([]);
const router = useRouter();

const goHome = () => {
  router.push("/home");
};

onMounted(async () => {
  try {
    const res = await axios.get("/tielingpowergriduavservice/users/getUsers");
    if (res.data && res.data.code === 200) {
      userList.value = res.data.data || [];
    } else {
      userList.value = [];
    }
  } catch {
    userList.value = [];
  }
});
</script>

<style scoped>
.user-manage-bg {
  height: 100vh;
  width: 100vw;
  background: linear-gradient(135deg, #e0f7fa 0%, #f8fafc 60%, #d1e9fc 100%);
  position: relative;
  overflow: hidden;
}
body,
html {
  height: 100%;
  width: 100%;
  overflow: hidden !important;
}
.user-manage-header {
  position: absolute;
  top: 40px;
  left: 60px;
  z-index: 10;
}
.back-btn {
  font-size: 16px;
  color: #31bfae;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(49, 191, 174, 0.08);
  padding: 8px 22px;
  border: none;
  transition: background 0.2s;
}
.back-btn:hover {
  background: #e0f7fa;
  color: #199893;
}
.user-manage-center {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 110px;
}
.user-info-card {
  width: 700px;
  min-height: 320px;
  box-shadow: 0 8px 32px rgba(44, 62, 80, 0.13);
  border-radius: 22px;
  background: #fff;
  padding: 48px 38px 36px 38px;
  margin-top: 0;
}
:deep(.el-descriptions__title) {
  font-size: 22px;
  color: #31bfae;
  font-weight: 600;
  margin-bottom: 10px;
}
:deep(.el-descriptions__label) {
  background: #f1f5f9;
  color: #7f8c8d;
  font-weight: 500;
  font-size: 16px;
  padding: 10px 16px;
}
:deep(.el-descriptions__content) {
  color: #2c3e50;
  font-size: 18px;
  padding: 10px 16px;
}
.user-manage-bg::before {
  content: "";
  position: absolute;
  left: -120px;
  top: 120px;
  width: 320px;
  height: 320px;
  background: radial-gradient(
    circle,
    #b2ebf2 0%,
    #e0f7fa 80%,
    transparent 100%
  );
  border-radius: 50%;
  z-index: 1;
  opacity: 0.5;
}
.user-manage-bg::after {
  content: "";
  position: absolute;
  right: -100px;
  bottom: 80px;
  width: 260px;
  height: 260px;
  background: radial-gradient(
    circle,
    #90caf9 0%,
    #d1e9fc 80%,
    transparent 100%
  );
  border-radius: 50%;
  z-index: 1;
  opacity: 0.4;
}
</style>
